<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
//用户夺宝纪录
class Go_member_go_record_model extends CI_Model{
    function __construct() {
        parent::__construct();
        $this->go_member_go_record = 'go_member_go_record';
        $this->users_info = 'users_info';
        $this->users = 'users';
    }
    
    //获取商品夺宝纪录总数
    function get_record_count($where){
        $this->db->select($this->go_member_go_record.'.*');
        $this->db->from($this->go_member_go_record);
        $this->db->where($where);
        return $this->db->get()->num_rows();
    }
    //获取商品夺宝单个纪录
    function get_record_one($where){
        $this->db->select($this->go_member_go_record.'.*,'
                .$this->users.".username,"
                .$this->users_info.".nickname,"
                .$this->users_info.".head_img");
        $this->db->from($this->go_member_go_record);
        $this->db->join($this->users_info,$this->users_info.".user_id = ".$this->go_member_go_record.".uid");
        $this->db->join($this->users,$this->users.".user_id = ".$this->go_member_go_record.".uid");
        $this->db->where($where);
        $this->db->order_by($this->go_member_go_record.".id DESC");
        $this->db->limit(1,0);
        return $this->db->get()->row_array();
    }
    
    //获取商品夺宝纪录列表
    function get_record_list($where,$page,$limit){
        $this->db->select($this->go_member_go_record.'.*'
                .$this->users.".username,"
                .$this->users_info.".nickname,"
                .$this->users_info.".head_img");
        $this->db->from($this->go_member_go_record);
        $this->db->join($this->users_info,$this->users_info.".user_id = ".$this->go_member_go_record.".uid");
        $this->db->join($this->users,$this->users.".user_id = ".$this->go_member_go_record.".uid");
        $this->db->order_by($this->go_member_go_record.".id DESC");
        $this->db->where($where);
        $this->db->limit($limit,$page);
        return $this->db->get()->result_array();
    }
    
}
